package com.heima.listener;

import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.support.Acknowledgment;
import org.springframework.stereotype.Component;

@Component
public class TestListener {
//	@KafkaListener(topics = "topic-1", groupId = "group1")
//	public void getMessage(String message) {
//		if (!StringUtils.isEmpty(message)) {
//			System.out.println("|||我是1号|||");
//			System.out.println(message);
//		}
//	}
//
//	@KafkaListener(topics = "topic-1", groupId = "group2")
//	public void getMessage2(String message) {
//		if (!StringUtils.isEmpty(message)) {
//			System.out.println("----我是2号----");
//			System.out.println(message);
//		}
//	}

    @KafkaListener(topics = "topic-1")
    public void onMessage2(ConsumerRecord<String, String> record, Acknowledgment acknowledgment) {
        System.out.println(record.value());
        acknowledgment.acknowledge();
    }
}
